package com.example.forum.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.forum.MyQuery;
import com.example.forum.entity.TJuwei;
import com.example.forum.service.ITJuweiService;
import com.example.forum.vo.JsonResult;
import com.example.forum.vo.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author why
 * @since 2020-04-22
 */
@RestController
@RequestMapping("JuWei")
public class TJuweiController {
    @Autowired
    ITJuweiService juweiService;

    /**
     * 居委查询
     * 前端参数大小写不一致
     * @return
     */
    @GetMapping("getJuWeis")
    public JsonResult getJuWeis(@RequestParam(defaultValue = "1") Integer pageIndex,
                                @RequestParam(defaultValue = "10") Integer pageSize,
                                String streetid){
        IPage<TJuwei> pageData = juweiService.page(
                new Page<>(pageIndex, pageSize),
                new MyQuery<TJuwei>().eq("StreetId", streetid)
        );
        return new JsonResult(HttpStatus.OK,"成功",new PageDto(pageData.getTotal(),pageData.getRecords()));
    }
}
